﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CPPEI.Coolzon.UI.ValueEditors
{
    /// <summary>
    /// IntegerEditor.xaml 的交互逻辑
    /// </summary>
    public partial class IntegerEditor : ValueEditor
    {
        public IntegerEditor()
        {
            InitializeComponent();
        }
        public override void SetValueString(string valueString)
        {
            this.tb.Text = valueString;
            base.SetValueString(valueString);
        }

        public override string GetValueString()
        {
            return this.tb.Text;
        }

        private void tb_KeyDown(object sender, KeyEventArgs e)
        {  
            //输入数字键、Backspace键则取消该输入
            int iKey = Convert.ToInt32(e.Key);
            if (!(iKey == 8 || (iKey >= 34 && iKey <= 43) || (iKey >=74 && iKey <= 83)))
            {
                e.Handled = true;
            }
        }
    }
}
